import javax.swing.tree.TreeNode;

/**
 * @ClassName test
 * @Description: leetcode最简单题目，判断二叉树结构相同
 * 二叉树对应节点值相同，主要考递归
 * @Author 40919
 * @Date 2020/4/21 0021 17:06
 * @Version v1.0
 **/
public class test {
    public static void main(String[] args) {

    }

    public class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(int x) { val = x; }
    }

    public boolean isSameTree(TreeNode p,TreeNode q){
        if (p==null&&q==null){
            return true;
        } else if (p==null||q==null){
            return false;
        }

        if(p!=null&&q!=null){
            if(p.val!=q.val){
                return false;
            }
            else {
                return isSameTree(p.left,q.left)&&isSameTree(p.right,q.right);
            }
        }
        return false;
    }

}
